#pragma once
//============================================================================
// Copyright (C) 2003Brett R. Jones
//
// Issued to public domain 2013
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================
//------------------------------------------------------------------------------
#define VX_DEFS 1
//------------------------------------------------------------------------------
// common type defines
//------------------------------------------------------------------------------
#define S8	char
#define U8	unsigned char
#define S16	short
#define U16	unsigned short
#define S32	long
#define U32	unsigned long
#define F32	float
#define F64	double
#define RCODE long

#ifdef WIN_PLATFORM // windows
	#define S64	__int64
	#define U64	unsigned __int64
    #ifndef _WINDEF_
        typedef unsigned long       DWORD;
        typedef int                 BOOL;
        typedef unsigned char       BYTE;
        typedef unsigned short      WORD;
        typedef float               FLOAT;
        typedef int                 INT;
        typedef unsigned int        UINT;
    #endif
	#define VxSleep(exp)		Sleep(exp) 
	#define VxGetLastError		GetLastError
#else // LINUX
    #ifndef TRUE
        #define TRUE 1
    #endif // TRUE
    #ifndef FALSE
        #define FALSE 0
    #endif // FALSE
    #ifndef NULL
        #define NULL 0
    #endif // NULL
    #define wxChar char
    #define INT int
	#define UINT unsigned int
    #define BOOL int
    #define CHAR char
	#define UCHAR unsigned char
    #define BYTE unsigned char
    #define SHORT short
	#define USHORT unsigned short
    #define WORD unsigned short
    #define LONG long
	#define ULONG unsigned long
    #define DWORD unsigned long
	#define S64	long long
	#define U64	unsigned long long

	//VxSleep.. sleep specified milliseconds
	#ifdef ANDROID_PLATFORM
		#include <time.h>
		// android doesnt have millisleep like most linux distributions but does have nano sleep
		inline void VxSleep( int iMilliSec )
		{
			timespec ts;
			ts.tv_sec = iMilliSec/1000;
			ts.tv_nsec = (iMilliSec%1000)*1000000;
			nanosleep(&ts, NULL);
		};		
	#else // android
		// normal linux
		//#define VxSleep(exp)		msleep(exp)
		#define VxSleep(exp)		usleep(exp * 1000)
	#endif //ANDROID_PLATFORM

	#define VxGetLastError()	errno
	#define HWND				void *
	#define MAX_PATH			512
	#define SOCKET				int		// use windows style socket define
	#define INVALID_SOCKET		-1		// use windows style socket define
	#define SOCKET_ERROR		-1		// use windows style socket define

	#ifndef max
		#define max(a,b)            (((a) > (b)) ? (a) : (b))
	#endif

	#ifndef min
		#define min(a,b)            (((a) < (b)) ? (a) : (b))
	#endif
#endif //LINUX

//------------------------------------------------------------------------------
// common macros
//------------------------------------------------------------------------------
#ifndef SAFE_DELETE
	#define SAFE_DELETE(p)			  {if(p) {delete (p);	(p)=0;}}
	#define SAFE_DELETE_ARRAY(p)	{if(p) {delete [] (p); (p)=0;}}
#endif //SAFE_DELETE

#define VxAbs(x) ((x)<0 ? -(x) : (x)) // get absolute value

#ifndef ROUND_TO_4BYTE_BOUNDRY
	#define ROUND_TO_4BYTE_BOUNDRY( a ) (( a + 3 ) & ~3 ) //round upto even 4 byte boundry
#endif //ROUND_TO_4BYTE_BOUNDRY
#ifndef ROUND_TO_8BYTE_BOUNDRY
	#define ROUND_TO_8BYTE_BOUNDRY( a ) (( a + 7 ) & ~7 ) //round upto even 8 byte boundry
#endif //ROUND_TO_8BYTE_BOUNDRY
#ifndef ROUND_TO_16BYTE_BOUNDRY
	#define ROUND_TO_16BYTE_BOUNDRY( a ) (( a + 15 ) & ~15 ) //round upto even 16 byte boundry
#endif //ROUND_TO_16BYTE_BOUNDRY

//------------------------------------------------------------------------------
// common supported files
//------------------------------------------------------------------------------
#define DATABASE_SUPPORTED_FILE_EXTENTIONS				"Supported Files (*.db)|*.db|All Files (*.*)|*.*||";
#define INI_SUPPORTED_FILE_EXTENTIONS					"Supported Files (*.ini)|*.ini|All Files (*.*)|*.*||";
#define TXT_SUPPORTED_FILE_EXTENTIONS					"Supported Files (*.txt)|*.ini|All Files (*.*)|*.*||";
#define CSV_SUPPORTED_FILE_EXTENTIONS					"Supported Files (*.csv)|*.csv|All Files (*.*)|*.*||";
#define GOB_SUPPORTED_FILE_EXTENTIONS					"Supported Files (*.gob)|*.gob|All Files (*.*)|*.*||";
#define BMP_SUPPORTED_FILE_EXTENTIONS					"Supported Files (*.bmp)|*.bmp|All Files (*.*)|*.*||";
#define TEXTURE_SUPPORTED_FILE_EXTENTIONS				"Texture Files (bmp jpg tga png pcx dds)|*.bmp;*.jpg;*.tga;*.png;*.dds;*.pcx|All Files (*.*)|*.*||";
#define MODEL_SUPPORTED_FILE_EXTENTIONS					"Mesh Files (x gmi g3d b3d md2 md3 3ds obj dmf mesh)|*.X;*.b3d;*.md2;*.md3;*.3ds;*.obj;*.dmf;*.mesh;|All Files (*.*)|*.*||";
#define XML_SUPPORTED_FILE_EXTENTIONS					"Supported Files (*.xml)|*.xml|All Files (*.*)|*.*||";
#define GAME_SETTINGS_SUPPORTED_FILE_EXTENTIONS			"Supported Files (*.vxg)|*.vxg|All Files (*.*)|*.*||";
#define HTML_SUPPORTED_FILE_EXTENTIONS					"Supported Files (htm html )|*.htm;*.html|All Files (*.*)|*.*||";
#define TGA_SUPPORTED_FILE_EXTENTIONS					"Targa(*.TGA)\0*.TGA\0All(*.*)\0*.*\0"
#define SOUND_SUPPORTED_FILE_EXTENTIONS					"Supported Files (*.wav)|*.wav|All Files (*.*)|*.*||";


